#include "mainwindow.h"
#include "ui_mainwindow.h"

#include "utils.h"

#include <QEvent>
#include <QMimeData>
#include <QShowEvent>
#include <QDebug>

MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    filter = new EventFilter(this);

    lineEdit = new LineEdit(this);
    ui->verticalLayout->insertWidget(2, lineEdit);

    this->installEventFilter(filter);
    ui->lineEdit->installEventFilter(filter);
    ui->label->installEventFilter(filter);
}

MainWindow::~MainWindow()
{
    delete filter;
    delete lineEdit;
    delete ui;
}

void MainWindow::showEvent(QShowEvent *event)
{
    if (event->type() == QEvent::Show) {
        fprintf(stdout, "X_WINDOW_ID=0x%llx\n", this->winId());
        fflush(stdout);
    }
    QMainWindow::showEvent(event);
}

void MainWindow::on_pushButton_clean_clicked()
{
    ui->lineEdit->clear();
}

void MainWindow::on_pushButton_exit_clicked()
{
    qApp->exit(0);
}

